﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Elkomp;

namespace MedicinskiUslugi {

	public partial class frmKorisnici : FormaBrowse {
		SqlConnection con = new SqlConnection();
		SqlCommand com = new SqlCommand();

		public frmKorisnici() {
			InitializeComponent();
			btnOk.Visible = false;
		}

		public frmKorisnici( bool zoom ) {
			InitializeComponent();
			btnOk.Visible = true;
			zoom = true;
		}

		private void SelcectionCHanged( object sender, EventArgs e ) {
			if ( this.tblKorisniciGrid.CurrentRow != null ) {
				dr = this.medicinskiUslugiDataSet.tblUsers[this.tblKorisniciGrid.CurrentRow.Index];
			}
		}

		public override void NovZapis( object sender, EventArgs e ) {
			this.tblKorisniciGrid.Insert();
			base.NovZapis( sender, e );
		}

		public override void IzmeniZapis( object sender, EventArgs e ) {
			this.tblKorisniciGrid.Edit();
			base.IzmeniZapis( sender, e );
		}

		private void frmKorisnici_Load( object sender, EventArgs e ) {
			Navigator.BindingSource = tblUsersBindingSource;
			this.tblUsersTableAdapter.Fill( this.medicinskiUslugiDataSet.tblUsers );
		}

		private void btnPrebaraj_Click( object sender, EventArgs e ) {
			this.tblUsersTableAdapter.Fill( this.medicinskiUslugiDataSet.tblUsers );

			this.tblUsersBindingSource.Filter = " FullName LIKE '%" + Naziv.Text + "%'";
		}

		private void tblKorisniciGrid_DataInsert() {
			this.tblUsersTableAdapter.Fill( this.medicinskiUslugiDataSet.tblUsers );
		}

		public override void IzbrisiZapis( object sender, EventArgs e ) {
			if ( this.tblKorisniciGrid.CurrentRow != null ) {
				DialogResult opc;
				opc = MessageBox.Show( "Дали сте сигурни ?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question );
				if ( opc == DialogResult.Yes ) {
					this.tblKorisniciGrid.Rows.Remove( tblKorisniciGrid.CurrentRow );
					this.tableAdapterManager.UpdateAll( this.medicinskiUslugiDataSet );
				}
			}

			base.IzbrisiZapis( sender, e );
		}
	}
}